package cn.zl.model;

import cn.yunbamboos.Model;
import cn.yunbamboos.mybatis.annotation.TableField;
import cn.yunbamboos.mybatis.annotation.TableName;
import cn.yunbamboos.mybatis.annotation.TablePrimaryKey;
import cn.yunbamboos.rest.service.anno.param.ParamType;
import cn.yunbamboos.rest.service.anno.param.enums.Type;
import com.alibaba.fastjson2.JSONObject;

@TableName(value = "zl_platform", cn = "国联级联平台表")
public class Platform implements Model {

    @TablePrimaryKey(value = "platform_id")
    private String platformId;
    @TableField(value = "enable")
    private boolean enable;
    @TableField(value = "platform_name")
    private String platformName;

    @ParamType(path = "update_time", type = Type.String, title = "更新时间", required = true, example = "2024-01-01 00:00:00")
    @TableField(value = "update_time")
    private String updateTime;

    @ParamType(path = "create_time", type = Type.String, title = "创建时间", required = true, example = "2024-01-01 00:00:00")
    @TableField(value = "create_time")
    private String createTime;

    @Override
    public JSONObject encode() {
        JSONObject json = new JSONObject();
        json.put("platform_id", platformId);
        json.put("enable", enable);
        json.put("platform_name", platformName);
        json.put("update_time", updateTime);
        json.put("create_time", createTime);
        return json;
    }

    @Override
    public void decode(JSONObject json) {
        if (json.containsKey("platform_id")) this.platformId = json.getString("platform_id");
        if (json.containsKey("enable")) this.enable = json.getBoolean("enable");
        if (json.containsKey("platform_name")) this.platformName = json.getString("platform_name");
        if (json.containsKey("update_time")) this.updateTime = json.getString("update_time");
        if (json.containsKey("create_time")) this.createTime = json.getString("create_time");
    }

    public String getPlatformId() {
        return platformId;
    }

    public void setPlatformId(String platformId) {
        this.platformId = platformId;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getPlatformName() {
        return platformName;
    }

    public void setPlatformName(String platformName) {
        this.platformName = platformName;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
}
